package com.xinzhi.service.impl;

import com.xinzhi.dao.ProductMapper;
import com.xinzhi.dao.ProductTypeMapper;
import com.xinzhi.entity.ProductType;
import com.xinzhi.entity.Result;
import com.xinzhi.service.ProductTypeService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class ProductTypeServiceImpl implements ProductTypeService {
    @Autowired
    private ProductMapper productMapper;
    @Autowired
    private ProductTypeMapper productTypeMapper;
    @Override
    public List<ProductType> getAllProductType() {
        return productTypeMapper.getAllOneProductType();
    }

    @Override
    public Result getProductTypeByTypeId(String productTypeId) {
        //判断接收参数是否未空
        if(productTypeId == null){
            return Result.error("一级类目id为空");
        }
        //不为空转换类型
        Integer tempProductTypeId = Integer.valueOf(productTypeId);
        return Result.ok(productTypeMapper.getProductTypeByOneTypeId(tempProductTypeId));
    }


}
